<?php
	require_once("../conexion/conexion.php");
	require_once("../Mantenedores/cliente.php");
	$cli = new Cliente();
	
	if(isset($_GET['fac']))
	{ $numFac = $_GET['fac'];}
	if(isset($_GET['doc']))
	{ $doc = $_GET['doc'];}
	if(isset($_GET['id']))
	{ $id = $_GET['id'];}
	if(isset($_GET['pago']))
	{ $pago = $_GET['pago'];}
	//echo $numFac." ".$doc." ".$id." ".$pago;
	//echo strtoupper('este es mi texto en minusculas que pasara a mayusculas');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ventana-Detalle-Historico</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />
<script src="../include_js/jquery.js" type="text/javascript"></script>
<style>
.filaPar
{
	background:#81D371; 
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.filaImpar
{
	background:#AEF1A1;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.lado
{
	border:1px solid #FFFFFF;
}
</style>
</head>

<body>
<form name="form_Ventana_historico" id="form_Ventana_historico" method="post" >
<div id="acpinner3">
<div id="acppage">
<div class="option2">
  <label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">Detalle de la Factura N&deg; <? echo $numFac;?> .</label>
</div>
<?php
	if($pago=='D')
	{
		//echo "deposito";
		//$rut = $cli->BuscaRut($cliente);
		//echo $rut;
		?>
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno" >
			<thead>
  			<tr>
    			<th width="22%" class="lado">N&deg; Dep&Oacute;sito</th>
    			<th width="49%" class="lado">Nombre emisor</th>
    			<th width="29%" class="lado">monto ($)</th>
  			</tr>
 			</thead>
			<?php
			$con = new Conexion();
			$con2 = $con->conexionBD("fpproduccion");
			$sql="select DepNum,DepNombre,DepMonto from deposito where DepFactura=$numFac and DepCod=$id and DepDoc='".$doc."'";
			$res = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
			$con->cerrarBD();
			$cont=1;
			while($reg = mysql_fetch_array($res))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"22%\" class=\"filaPar\">".$reg['DepNum']."</td>";
					echo "<td width=\"49%\" class=\"filaPar\">".$reg['DepNombre']."</td>";
					echo "<td width=\"29%\" class=\"filaPar\">$".number_format ($reg['DepMonto'],0,',','.')."</td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"22%\" class=\"filaImpar\">".$reg['DepNum']."</td>";
					echo "<td width=\"49%\" class=\"filaImpar\">".$reg['DepNombre']."</td>";
					echo "<td width=\"29%\" class=\"filaImpar\">$".number_format ($reg['DepMonto'],0,',','.')."</td>";
					echo "</tr>";
				}
				$cont++;
			}
			?>
	  </table>
		<?php
	}
	else
	{
		if($pago=='CH')
		{	//echo "cheque";
		?>
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno" >
			<thead>
  			<tr>
    			<th width="17%" class="lado">N&deg; cheque</th>
    			<th width="17%" class="lado">monto ($)</th>
    			<th width="22%" class="lado">fecha pago cheque</th>
				<th width="44%" class="lado">banco</th>
  			</tr>
 			</thead>
			<?php
			$con = new Conexion();
			$con2 = $con->conexionBD("fpproduccion");
			$sql="select ChequeNum,ChequeMonto,date_format(ChequeFechaPago,'%d/%m/%Y') as fecha,BancoNombre from cheques inner join banco on banco.BancoCod=cheques.BancoCod where ChequeFactura=$numFac and ChequeCod=$id and ChequeDoc='".$doc."'";
			$res = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
			$con->cerrarBD();
			$cont=1;
			while($reg = mysql_fetch_array($res))
			{
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"17%\" class=\"filaPar\">".$reg['ChequeNum']."</td>";
					echo "<td width=\"17%\" class=\"filaPar\">$".number_format ($reg['ChequeMonto'],0,',','.')."</td>";
					echo "<td width=\"22%\" class=\"filaPar\">".$reg['fecha']."</td>";
					echo "<td width=\"44%\" class=\"filaPar\">".$reg['BancoNombre']."</td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"17%\" class=\"filaImpar\">".$reg['ChequeNum']."</td>";
					echo "<td width=\"17%\" class=\"filaImpar\">$".number_format ($reg['ChequeMonto'],0,',','.')."</td>";
					echo "<td width=\"22%\" class=\"filaImpar\">".$reg['fecha']."</td>";
					echo "<td width=\"44%\" class=\"filaImpar\">".$reg['BancoNombre']."</td>";
					echo "</tr>";
				}
				$cont++;
			}
			?>
	  </table>
		<?php
		}
		else
		{
			if($pago=='E')
			{
				//echo "efectivo";
				?>
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno" >
				<thead>
  				<tr>
    				<th width="34%" class="lado">cliente</th>
    				<th width="23%" class="lado">factura</th>
    				<th width="21%" class="lado">fecha ingreso</th>
					<th width="22%" class="lado">monto ($)</th>
  				</tr>
 				</thead>
				<?php
				$con = new Conexion();
				$con2 = $con->conexionBD("fpproduccion");
				$sql="select CliRSocial,EfectivoFactura,date_format(EfectivoFecha,'%d/%m/%Y') as fecha,EfectivoMonto from efectivo inner join clientes on clientes.CliRut=efectivo.CliRut where EfectivoFactura=$numFac and EfectivoCod=$id and EfectivoDoc='".$doc."'";
				$res = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
				$con->cerrarBD();
				$cont=1;
				while($reg = mysql_fetch_array($res))
				{
					if(($cont % 2)==0)
					{
						echo "<tr class=\"filaPar\">";
						echo "<td width=\"34%\" class=\"filaPar\">".$reg['CliRSocial']."</td>";
						echo "<td width=\"23%\" class=\"filaPar\">".$reg['EfectivoFactura']."</td>";
						echo "<td width=\"21%\" class=\"filaPar\">".$reg['fecha']."</td>";
						echo "<td width=\"22%\" class=\"filaPar\">$".number_format ($reg['EfectivoMonto'],0,',','.')."</td>";
						echo "</tr>";
					}
					else
					{
						echo "<tr class=\"filaImpar\">";
						echo "<td width=\"34%\" class=\"filaImpar\">".$reg['CliRSocial']."</td>";
						echo "<td width=\"23%\" class=\"filaImpar\">".$reg['EfectivoFactura']."</td>";
						echo "<td width=\"21%\" class=\"filaImpar\">".$reg['fecha']."</td>";
						echo "<td width=\"22%\" class=\"filaImpar\">$".number_format ($reg['EfectivoMonto'],0,',','.')."</td>";
						echo "</tr>";
					}
					$cont++;
				}
				?>
	  			</table>
				<?php
			}
			else
			{
				if($pago=='V')
				{
					//echo "vale vista";
					?>
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno" >
				<thead>
  				<tr>
    				<th width="29%" class="lado">N&deg; vale vista</th>
    				<th width="30%" class="lado">monto ($)</th>
    				<th width="41%" class="lado">banco</th>
  				</tr>
 				</thead>
				<?php
				$con = new Conexion();
				$con2 = $con->conexionBD("fpproduccion");
				$sql="select ValNumero,ValMonto,BancoNombre from valevista inner join banco on banco.BancoCod=valevista.BancoCod where ValFactura=$numFac and ValCod=$id and ValDoc='".$doc."'";
				$res = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
				$con->cerrarBD();
				$cont=1;
				while($reg = mysql_fetch_array($res))
				{
					if(($cont % 2)==0)
					{
						echo "<tr class=\"filaPar\">";
						echo "<td width=\"29%\" class=\"filaPar\">".$reg['ValNumero']."</td>";
						echo "<td width=\"30%\" class=\"filaPar\">$".number_format ($reg['ValMonto'],0,',','.')."</td>";
						echo "<td width=\"41%\" class=\"filaPar\">".$reg['BancoNombre']."</td>";
						echo "</tr>";
					}
					else
					{
						echo "<tr class=\"filaImpar\">";
						echo "<td width=\"29%\" class=\"filaImpar\">".$reg['ValNumero']."</td>";
						echo "<td width=\"30%\" class=\"filaImpar\">$".number_format ($reg['ValMonto'],0,',','.')."</td>";
						echo "<td width=\"41%\" class=\"filaImpar\">".$reg['BancoNombre']."</td>";
						echo "</tr>";
					}
					$cont++;
				}
				?>
	  			</table>
				<?php
				}
				else
				{
					if($pago=='T')
					{
						//echo "transferencia";
						?>
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="uno" >
				<thead>
  				<tr>
    				<th width="29%" class="lado">N&deg; cuenta</th>
    				<th width="30%" class="lado">monto ($)</th>
    				<th width="41%" class="lado">N&deg; cuenta emisor</th>
  				</tr>
 				</thead>
				<?php
				$con = new Conexion();
				$con2 = $con->conexionBD("fpproduccion");
				$sql="select TransNumero,TransMonto,TransCuenta from transferencia where TransFactura=$numFac and TransCod=$id and TransDoc='".$doc."'";
				$res = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
				$con->cerrarBD();
				$cont=1;
				while($reg = mysql_fetch_array($res))
				{
					if(($cont % 2)==0)
					{
						echo "<tr class=\"filaPar\">";
						echo "<td width=\"29%\" class=\"filaPar\">".$reg['TransNumero']."</td>";
						echo "<td width=\"30%\" class=\"filaPar\">$".number_format ($reg['TransMonto'],0,',','.')."</td>";
						echo "<td width=\"41%\" class=\"filaPar\">".$reg['TransCuenta']."</td>";
						echo "</tr>";
					}
					else
					{
						echo "<tr class=\"filaImpar\">";
						echo "<td width=\"29%\" class=\"filaImpar\">".$reg['TransNumero']."</td>";
						echo "<td width=\"30%\" class=\"filaImpar\">$".number_format ($reg['TransMonto'],0,',','.')."</td>";
						echo "<td width=\"41%\" class=\"filaImpar\">".$reg['TransCuenta']."</td>";
						echo "</tr>";
					}
					$cont++;
				}
				?>
	  			</table>
				<?php
					}
				}
			}
		}
	}
?>
</div>
</div>
</form>
</body>
</html>
